
{extend name="base_iframe" /}

{block name="css"}

{/block}


{block name="body"}
<div>

	<!-- 选项卡 -->
	<ul class="nav nav-tabs" role="tablist" form-data="basics">
		<li role="presentation" class="active"><a href="#basics" aria-controls="basics" role="tab" data-toggle="tab">基本信息</a></li>
		<li role="presentation" ><a href="#album" aria-controls="album" role="tab" data-toggle="tab">商品图片</a></li>
		<li role="presentation"><a href="#details" aria-controls="details" role="tab" data-toggle="tab">商品详情</a></li>
		<li role="presentation"><a href="#goodsAttr" aria-controls="goodsAttr" role="tab" data-toggle="tab">商品属性</a></li>
		<li role="presentation"><a href="#other" aria-controls="other" role="tab" data-toggle="tab">其他信息</a></li>
		<li role="presentation"><a href="#userPrice" aria-controls="userPrice" role="tab" data-toggle="tab">会员价格</a></li>
	</ul>

	<!-- 内容 -->
	<div class="tab-content">
		<!-- 基本信息 -->
		<div role="tabpanel" class="tab-pane active" id="basics">
			<form class="form-horizontal basics"  method="post" >
				<input type="hidden" name="id" value="{$data.id}"/>
				<input type="hidden" name="scene" value="editBasics"/>

				<div class="row box-ota-info">
					<div class="col-md-12">
						<div class="box-body">

							<div class="form-group">
								<div class="col-sm-2"></div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">商品名称</label>
								<div class="col-sm-8">
									<input type="text" class="form-control" name="goods_name" placeholder="请输入商品名称" value="{$data.goods_name}" />
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">商品分类</label>
								<div class="col-sm-4" id="cate-div">
									<select class="form-control cate-select"  name="cate_id" data-url="{:url('admin/GoodsBrand/ajaxGetBrand')}">
										<option value="">请选择商品分类</option>}
										{volist name="cateInfo" id="v"}
											<option value="{$v.id}" {$data.cate_id == $v.id ? 'selected': ''}>{$v.level ? "|" : ""} {:str_repeat("——", $v.level)} {$v.cate_name}</option>
										{/volist}
									</select>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">所属品牌</label>
								<div class="col-sm-4">
									<select class="form-control brand-select" name="brand_id">
										<option value="">请选择商品品牌</option>}
										{volist name="brandInfo" id="v"}
											<option value="{$v.brand_id}" {$data.brand_id == $v.brand_id ? 'selected': ''}> {$v.brand_name}</option>
										{/volist}
									</select>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">商品货号</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" name="goods_sn" placeholder="请输入货号" value="{$data.goods_sn}" />
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">当前售价</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" name="now_price" placeholder="售价请按此格式填写, 如: '188.00'" value="{$data.now_price}" />
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">原售价</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" name="original_price" placeholder="留空或为0时，前台不显示原售价" value="{$data.original_price}" />
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">促销价格</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" name="promote_price" placeholder="如促销价格且在时间范围内，优先于会员价格" value="{$data.promote_price}" />
								</div>

								<div class="input-group col-sm-4">
									<div class="input-group-addon">
										<i class="fa fa-calendar"></i>
									</div>
									<input type="text" name="promote_start_time" readonly value="{$data.promote_start_time|date="Y-m-d",###}" class="form-control pull-right datepicker-style" placeholder="开始时间">

									<div class="input-group-addon">
										<i class="fa fa-calendar"></i>
									</div>
									<input type="text" name="promote_end_time" readonly value="{$data.promote_end_time|date="Y-m-d",###}" class="form-control pull-right datepicker-style" placeholder="结束时间">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">商品简介</label>
								<div class="col-sm-8">
									<script id="goods_brief" name="goods_brief" type="text/plain" style="width:100%;height:30%;">{$data.goods_brief}</script>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">标记</label>
								<div class="col-sm-2">
									<div class="checkbox">
										<label>
											<input type="checkbox" name="newarrival" {$data.newarrival? 'checked': ''} value="1">&nbsp;&nbsp;&nbsp;&nbsp;新品
										</label>
									</div>
								</div>
								<div class="col-sm-2">
									<div class="checkbox">
										<label>
											<input type="checkbox" name="bargain" {$data.bargain? 'checked': ''} value="1">&nbsp;&nbsp;&nbsp;&nbsp;特价
										</label>
									</div>
								</div>

								<div class="col-sm-2">
									<div class="checkbox">
										<label>
											<input type="checkbox" name="recommend" {$data.recommend? 'checked': ''} value="1">&nbsp;&nbsp;&nbsp;&nbsp;推荐
										</label>
									</div>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">状态</label>
								<div class="col-sm-2">
									<select class="form-control" name="status">
										<option value="1" {$data.status? 'selected': ''}>上架</option>
										<option value="0" {$data.status? '': 'selected'}>下架</option>
									</select>
								</div>
							</div>

						</div>
					</div>
				</div>
			</form>
		</div>
		<!-- 商品图片 -->
		<div role="tabpanel" class="tab-pane" id="album">

			<form class="form-horizontal album"  method="post" >
				<input type="hidden" name="id" value="{$data.id}"/>
				<input type="hidden" name="scene" value="editAlbum"/>
				<div class="row box-ota-info">
					<div class="col-md-12">
						<div class="box-body">

							<div class="form-group">
								<div class="col-sm-2"></div>
							</div>

							<div class="form-group">
								<div class="col-sm-10">
									<div>
										<a class="btn btn-app upload-img-btn" data-url="{:url('uploadImagePage')}" data-id="{$data.id}">
											<i class="fa fa-cloud-upload"></i> 上传图片
										</a>
									</div>


									{if condition="$albumInfo"}
										<div class="row margin-bottom" id="image-div">
											{volist  name="albumInfo" id="v"}
												<div class="col-lg-3 col-xs-4" >
													<!-- small box -->
													<div class="small-box bg-aqua">
														<div class="inner">
															<img class="img-responsive img-thumbnail center-block" src={$v.image|show_image="goods_album",###} alt="Photo">
														</div>

														<a href="javascript:;" class="small-box-footer delete-image" data-id="{$v.id}" data-url="{:url('deleteAlbum')}">
															删除 <i class="fa fa-close"></i>
														</a>
													</div>
												</div>
											{/volist}
										</div>
									{/if}
								</div>
							</div>

						</div>
					</div>
				</div>

			</form>

		</div>
		<!-- 商品详情 -->
		<div role="tabpanel" class="tab-pane" id="details">
			<form class="form-horizontal details"  method="post" >
				<input type="hidden" name="id" value="{$data.id}"/>
				<input type="hidden" name="scene" value="editDetails"/>
				<script id="container" name="goods_content" type="text/plain" style="width:100%;height:80%;">{$data.goods_content}</script>
			</form>
		</div>
		<!-- 商品属性 -->
		<div role="tabpanel" class="tab-pane" id="goodsAttr">

			


			<form class="form-horizontal goodsAttr"  method="post" >
				<input type="hidden" name="id" value="{$data.id}"/>
				<input type="hidden" name="scene" value="editGoodsAttr"/>
				<div class="row box-ota-info">
					<div class="col-md-12">
						<div class="box-body">

							<div class="form-group">
								<div class="callout callout-danger col-md-12">
									<h4>注意</h4>

									<p>1.属性值不选择或者留空，点击修改，则代表删除！</p>
									<p>2.选择其他商品类型，点击修改，会把原来属性值和规格值全部删除！</p>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">商品类型</label>
								<div class="col-sm-8">
									<select class="form-control select-type" name="type_id" goods-id="{$data.id}" data-url="{:url('admin/TypeAttr/ajaxGetAttr')}">
										<option value="">请选择商品类型</option>}
										{volist name="typeInfo" id="v"}
											<option value="{$v.id}" {$data.type_id == $v.id ? 'selected': ''}> {$v.type_name}</option>
										{/volist}
									</select>
								</div>
							</div>


							<div class="attr-div">
							<!-- 已经出现过的属性id -->
							{php}$attrIds = array();{/php}

							{volist name="goodsAttrViewInfo" id="v" key="k"}
								{php}
									if(in_array($v['attr_id'], $attrIds)){
		    							$opt = '[-]';
									} else {
			    						$opt = '[+]';
			    						$attrIds[] = $v['attr_id'];
			    					}

			    					if($v['attr_value'] == ''){
				    					$old_ = '';
			    					} else {
				    					$old_ = 'old_';
			    					}

								{/php}

								<div class='form-group'>
									<label class='col-sm-2 control-label'>{$v.attr_name}</label>

									{if condition="$v.opts == ''"}
										<div class='col-sm-2'>
											<input type='text' class='form-control attr-value' name="{$old_}attr_value[{$v.attr_id}][{$v.goods_attr_id}]" value="{$v.attr_value}" placeholder='请输入属性值'/>
										</div>
									{else /}
										{php}
											$_arr = explode("\n", $v['opts']);
										{/php}
										<div class='col-sm-2'>
											<select class='form-control attr-value' name="{$old_}attr_value[{$v.attr_id}][{$v.goods_attr_id}]">
												<option value=''>请选择</option>
												{volist name="$_arr" id="v1" key="k1"}
													<option {if condition='str_replace("\n", "", $v1)  == str_replace("\n", "", $v.attr_value)'}selected="selected"{/if} value='{$v1}'>{$v1}</option>
												{/volist}
											</select>
										</div>
									{/if}

									{if condition="$v.is_select == 1"}
										<div class='col-sm-1'>
											<h5>属性价格 </h5>
										</div>

										<div class='col-sm-2'>
											<input name="{$old_}attr_price[{$v.attr_id}][{$v.goods_attr_id}]" class='form-control attr-price' type='text' value="{$v.attr_price}" placeholder='请输入属性价格'/>
										</div>

										<div class='col-md-1'>
											<a class='clone-this' href='javascript:void(0);'>{$opt}</a>
										</div>

									{/if}
								</div>
							{/volist}
							</div>

						</div>
					</div>
				</div>
			</form>

		</div>

		<!-- 其他 -->
		<div role="tabpanel" class="tab-pane" id="other">
			<form class="form-horizontal other"  method="post" >
				<input type="hidden" name="id" value="{$data.id}"/>
				<input type="hidden" name="scene" value="editOther"/>
				<div class="row box-ota-info">
					<div class="col-md-12">
						<div class="box-body">

							<div class="form-group">
								<div class="col-sm-2"></div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">库存数量</label>
								<div class="col-sm-2">
									<input type="text" class="form-control" name="stock_qty" placeholder="请输入商品库存" value="{$data.stock_qty}" />
								</div>
								<div><small><h5>/ 件</h5></small></div>
							</div>	

							<div class="form-group">
								<label class="col-sm-2 control-label">商品重量</label>
								<div class="col-sm-2">
									<input type="text" class="form-control" name="goods_weight" placeholder="请输入商品重量" value="{$data.goods_weight}" /> 
								</div>
								<div><small><h5>/ 千克</h5></small></div>
							</div>


							<div class="form-group">
								<label class="col-sm-2 control-label">关键词</label>
								<div class="col-sm-8">
									<input type="text" class="form-control" name="meta_keywords" placeholder="请输入商品关键词，多个用逗号隔开" value="{$data.meta_keywords}" />
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">描述</label>
								<div class="col-sm-8">
									<textarea class="form-control textarea" name="meta_description" rows="5">{$data.meta_description}</textarea>
								</div>
							</div>
						</div>
					</div>
				</div>

			</form>

		</div>

		<!-- 会员价格 -->
		<div role="tabpanel" class="tab-pane" id="userPrice">
			<form class="form-horizontal userPrice"  method="post" >
				<input type="hidden" name="id" value="{$data.id}"/>
				<input type="hidden" name="scene" value="editUserPrice"/>
				<div class="row box-ota-info">
					<div class="col-md-12">
						<div class="box-body">

							<div class="form-group">
								<div class="callout callout-danger col-md-12">
									<h4>注意</h4>
									<p>如某级别会员价格留空，则该级别的会员价格为原价乘以该会员级别的折购率</p><a href="{:url('admin/UserRank/index')}" target="_blank">点击查看会员级别折购率</a>
								</div>
							</div>

							<div class="form-group">
								<div class="col-sm-2"></div>
							</div>

							{volist name="userRankInfo" id="v"}
								<div class="form-group">
									<label class="col-sm-2 control-label">{$v.rank_name}</label>
									<div class="col-sm-2">
										<input type="text" class="form-control" name="user_rank_price[{$v.id}]" value="{$v.price}" />
									</div>
									<div><small><h5>/ 元</h5></small></div>
								</div>
							{/volist}
						</div>
					</div>
				</div>

			</form>

		</div>


	</div>

</div>

{/block}


{block name="script"}
	<script type="text/javascript" src="__AJS__/goods/edit.js"></script>
{/block}